Skip to content

fix(socket): re-raise CancelledError instead of silently swallowing#2921

Open
hobostay wants to merge 1 commit into
Chainlit:mainfrom
hobostay:fix/cancelled-error-handling
Open

fix(socket): re-raise CancelledError instead of silently swallowing#2921
hobostay wants to merge 1 commit into
Chainlit:mainfrom
hobostay:fix/cancelled-error-handling

Conversation

@hobostay
Copy link
Copy Markdown

@hobostay hobostay commented May 10, 2026

Re-raise CancelledError instead of silently catching and passing in four SocketIO event handlers. This ensures tasks are properly marked as cancelled while still allowing finally blocks to execute for cleanup.


Summary by cubic

Re-raise asyncio.CancelledError in SocketIO event handlers so cancellation propagates and tasks are correctly marked as cancelled. Cleanup in finally blocks is unaffected.

  • Bug Fixes
    • Updated handlers: process_message, edit_message, window_message, audio_end.
    • Prevents masked cancellations; callers using task.cancelled() now get accurate state.

Written for commit f1c49cc. Summary will update on new commits.

Several SocketIO event handlers caught `asyncio.CancelledError` and
passed without re-raising. This masks cancellation signals and causes
the task to appear as completed rather than cancelled, which can lead
to incorrect state in callers that check `task.cancelled()`.

The `finally` blocks still execute on re-raise, so cleanup (e.g.
`task_end()`) remains unaffected.

Affected handlers: process_message, edit_message, window_message,
audio_end.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. backend Pertains to the Python backend. bug Something isn't working labels May 10, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Pertains to the Python backend. bug Something isn't working size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant